$(function () {
    $('.btnLogin').on('click', function () {
        // 非空判断
        if ('.btnLogin'.trim().length === 0) {
            alert('请重新登录');
        }

        $.ajax({
            type: "post",
            url: "/login",
            data: $('form').serialize(),
            dataType: "json",
            success: function (res) {
                if (res.code === 200) {
                    alert('登录成功');
                    location.href = '/admin'
                } else {
                    $('.alert-danger span').text(res.msg);
                    // 错误弹框--fadeIn淡入--delay--延迟时间--fadeOut淡出
                    $('.alert-danger').fadeIn(500).delay(20000).fadeOut(5000);
                }
            }
        });
    })
})